<?php
/**
 * 相关url
 *
 * */
class Util_BaseUrls {

    /**
     *功能： 获取QA URL
     */
    public static function build_base_url() {
        $apf = APF::get_instance();
        $base_domain = $apf->get_config("base_domain");
        $url = "http://" . $base_domain . "/qa/";
        return $url;
    }
    public static function home_url(){
        $apf = APF::get_instance();
        $base_domain = $apf->get_config("base_domain");
        $url = "http://" . $base_domain . "/";
        return $url;
    }
    /**
     * menu
     * @param string $menu
     * @return string
     */
    public static function build_menu_url($menu){
        return self::build_base_url().$menu.'/';
    }
    /**
     * 财务问答
     */
    public static function finance_list_url($id=""){
        if($id && is_numeric($id)){
            return self::build_base_url().Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE).'/?cate='.$id;
        }
        return self::build_base_url().Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE).'/';
    }
    /**
     * 财务问答_搜索
     */
    public static function finance_search_url($search_text="",$id=""){
        if($id && is_numeric($id)){
            return self::build_base_url().Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE).'/list/?cate='.$id."&search_text=".$search_text;
        }
        return self::build_base_url().Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE).'/list/?search_text='.$search_text;
    }
    /**
     * 财务问答_新增,删除,修改问答页面
     */
    public static function finance_add_qa($cate=1,$id=""){
        if($cate && is_numeric($cate)){
            $ext = $id?"&qid=$id":"";
            return self::build_menu_url(Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE))."add/?cate=".$cate.$ext;
        }
        return self::build_base_url().Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE).'/qa/';
    }
    /**
     * 财务问答_新增,删除,修改表单页面
     */
    public static function finance_new_qa($cate=1,$id=""){
        if($cate && is_numeric($cate)){
            $ext = $id?"&qid=$id":"";
            return self::build_menu_url(Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE))."new/?cate=".$cate.$ext;
        }
        return self::build_base_url().Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE).'/qa/';
    }
    /**
     * 财务问答_新增,删除,修改表单页面
     */
    public static function finance_delete_qa($id=""){
        if($id && is_numeric($id)){
            return self::build_menu_url(Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE))."delete/?qid=$id";
        }
        return self::build_base_url().Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE).'/qa/';
    }
    /**
     * 财务问答_表单下载页面
     */
    public static function finance_download_qa($id=""){
        if($id && is_numeric($id)){
            return self::build_menu_url(Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE))."download/".$id;
        }
        return self::build_base_url().Const_Qa::get_menu_list_en(Const_Qa::TAG_FINANCE).'/qa/';
    }

    public static function ajax_get_answer($id){

    }
    public static function click_link_hits(){
        return self::build_base_url()."ajax/click/";
    }
    /**
     * 用户头像
     * @param string $img_name  = user_code
     * @param int $size  7070=70*70
     * @return string
     */
    public static function build_form_file_path($file_name){
        $url = self::base_url() . "upload/" ;
        $user_head_pic = $user_code.'/'.$img_name;
        if(!is_file(Const_Img::PATH_BASE.Const_Img::PATH_UPLOAD.$user_head_pic)) {
            $user_head_pic = 'default.png';
        }
        return $url.$user_head_pic;
    }
    /**
     * 提示页面跳转链接
     * @params array URL后面参数
     */
    public static function build_jump_url($params){
       return self::build_base_url().'error/ShowTips/'.$params;
    }
    /**
     * 提示页面跳转链接
     * @params array URL后面参数
     */
    public static function login_out(){
        return self::build_base_url().'?logout=logouts';
    }
    public static function image_upload(){
        return self::build_base_url().'image/upload/';
    }
    /**
     *
     * @param string $url
     */
    public static function qa_image_url($file){
        return self::home_url().'qadoc/wd/'.$file;
    }

}